package com.prd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.prd.dto.OaAppointmentOrganizeDTO;
import com.prd.model.OaAppointmentOrganizeDO;
import com.prd.mapper.OaAppointmentOrganizeMapper;
import com.prd.service.OaAppointmentOrganizeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.prd.util.JsonData;
import com.prd.util.StringUtils;
import com.prd.vo.OaAppointmentRequestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 组织任命数据表 服务实现类
 * </p>
 *
 * @author lizhaoyi
 * @since 2024-01-21
 */
@Service
public class OaAppointmentOrganizeServiceImpl extends ServiceImpl<OaAppointmentOrganizeMapper, OaAppointmentOrganizeDO> implements OaAppointmentOrganizeService {

    @Autowired
    private OaAppointmentOrganizeMapper organizeMapper;

    /**
     * 职务变动列表
     * @return
     */
    @Override
    public JsonData getList() {
        return JsonData.buildSuccess(organizeMapper.selectList(new QueryWrapper<>()));
    }


    /**
     * 职务变动分页列表
     * @param requestVo
     * @return
     */
    @Override
    public JsonData getPage(OaAppointmentRequestVo requestVo) {

        Page<OaAppointmentOrganizeDO> page = new Page<>(requestVo.getPage(), requestVo.getSize());
        Page<OaAppointmentOrganizeDO> organizeDOPage = organizeMapper.selectPage(page, new QueryWrapper<OaAppointmentOrganizeDO>()
                .eq(requestVo.getStatus() != null, "status", requestVo.getStatus())
                .eq(StringUtils.isNotEmpty(requestVo.getDept()), "new_dept", requestVo.getDept()));

        Map<String,Object> resultMap = new HashMap<>(3);
        resultMap.put("total",organizeDOPage.getTotal());
        resultMap.put("pages",organizeDOPage.getPages());
        resultMap.put("rows",organizeDOPage.getRecords());

        return JsonData.buildSuccess(resultMap);
    }

    /**
     * 组织考察任命-提交审核
     * @param organizeDTO
     * @return
     */
    @Override
    public JsonData submit(OaAppointmentOrganizeDTO organizeDTO) {



        return null;
    }
}
